import java.util.Random;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:
 * Date: 2024-05-19
 * Time: 15:53
 */
public class Test {
    public static void main(String[] args) {
        int count = 0;
        System.out.println("已生成100以内的一个任意数");
        System.out.println("请输入想猜的数：");
        Scanner sc = new Scanner(System.in);
        Random random = new Random();
        int toGuess = random.nextInt(100);
        while(toGuess != 0){
            int num = sc.nextInt();
            if(num > toGuess){
                System.out.println("猜大了");
                count++;
            }else if(num < toGuess){
                System.out.println("猜小了");
                count++;
            }else{
                System.out.println("猜对了");
                break;
            }
            if(count == 5){
                break;
            }
        }
        System.out.println(toGuess);
        sc.close();
    }
}
